<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" %> 
<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Master Log</title>
</head>
<body>
<h2 align="center">Master Log</h2>
<table border=2 align="center">
<tr style="background-color:#4b545f"><th><font color=white>Master Type</font></th><th><font color=white>Master Log Details</font></th><th><font color=white>Date and Time</font></th></tr>
<%
DBConnection dbc=new DBConnection();
Connection con=dbc.getNewConnection();
Statement st = null;
ResultSet rs = null;
String name1="",date="",dtecreate="",intime="";


	System.out.println("MySQL Connect Example.");
	

	  java.util.Date now = new java.util.Date();
	  String DATE_FORMAT = "yyyy-MM-dd";
	  SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
	  Calendar calendar = Calendar.getInstance();
  String strDateNew = sdf.format(now) ;
  calendar.setTime(sdf.parse(strDateNew));
  calendar.add(Calendar.DATE,-10); 
  String dte = sdf.format(calendar.getTime());

  
  calendar.setTime(sdf.parse(strDateNew));
  calendar.add(Calendar.DATE,1); 
  String dte1 = sdf.format(calendar.getTime());
  

try
{
	  st=con.createStatement() ;
	  rs=st.executeQuery("select cname,datecreated, ccode from customermaster where datecreated between '"+dte+"' and '"+dte1+"';");
while(rs.next()){
	name1=rs.getString(1);
	if((rs.getString(2)!=null && rs.getString(2)!=""))
	  {
	  dtecreate = rs.getString(2).toString().substring(0,rs.getString(2).toString().indexOf("."));
	  try
	 {
	 now = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse( dtecreate);
	  sdf = new SimpleDateFormat("hh:mm:ss, dd-MM-yyyy");
	  intime = sdf.format(now);
	  }
	  catch (Exception e)
	  {
	  e.getMessage();
	  }
	  }
	String cd=rs.getString(3);
	%>


<tr><td>Customer Creation</td><td>New Customer created <a href="http://localhost:8081/boa/LedgerReportServlet?vouchernumber=<%=cd%>&group=Credit"><%=name1 %></a></td><td><%=intime %></td></tr>


<%}} 
catch(Exception e) {} %>


<%-- 
<%
try
{
	  st=con.createStatement() ;
	  rs=st.executeQuery("select cname,dateedited from customermaster where dateedited between '"+dte+"' and '"+dte1+"';");
while(rs.next()){
	name1=rs.getString(1);
	if((rs.getString(2)!=null && rs.getString(2)!=""))
	  {
	  dtecreate = rs.getString(2).toString().substring(0,rs.getString(2).toString().indexOf("."));
	  try
	 {
	 now = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse( dtecreate);
	  sdf = new SimpleDateFormat("hh:mm:ss, dd-MM-yyyy");
	  intime = sdf.format(now);
	  }
	  catch (Exception e)
	  {
	  e.getMessage();
	  }
	  }
	%>


<tr><td>Customer Creation</td><td> Customer <a href="#"><%=name1 %></a> Updated</td><td><%=intime %></td></tr>


<%}} 
catch(Exception e) {} %>

--%>

<%
try
{
	  st=con.createStatement() ;
	  rs=st.executeQuery("select sname,datecreated from suppliermaster where datecreated between '"+dte+"' and '"+dte1+"';");
while(rs.next()){
	name1=rs.getString(1);
	if((rs.getString(2)!=null && rs.getString(2)!=""))
	  {
	  dtecreate = rs.getString(2).toString().substring(0,rs.getString(2).toString().indexOf("."));
	  try
	 {
	 now = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse( dtecreate);
	  sdf = new SimpleDateFormat("hh:mm:ss, dd-MM-yyyy");
	  intime = sdf.format(now);
	  }
	  catch (Exception e)
	  {
	  e.getMessage();
	  }
	  }
	%>


<tr><td>Supplier Creation</td><td>New Supplier created <a href="#"><%=name1 %></a></td><td><%=intime %></td></tr>

<%}} 
catch(Exception e) {} %>

<%
try
{
	  st=con.createStatement() ;
	  rs=st.executeQuery("select gname,ggroup,datecreated from generalledger2 where datecreated between '"+dte+"' and '"+dte1+"';");
while(rs.next()){
	name1=rs.getString(1);
   String grp=rs.getString(2);
	if((rs.getString(3)!=null && rs.getString(2)!=""))
	  {
	  dtecreate = rs.getString(3).toString().substring(0,rs.getString(3).toString().indexOf("."));
	  try
	 {
	 now = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse( dtecreate);
	  sdf = new SimpleDateFormat("hh:mm:ss, dd-MM-yyyy");
	  intime = sdf.format(now);
	  }
	  catch (Exception e)
	  {
	  e.getMessage();
	  }
	  }
	%>


<tr><td>General Ledger Creation</td><td>New Ledger <a href="#"><%=name1 %></a> under <%=grp %></td><td><%=intime %></td></tr>




<%}} 
catch(Exception e) {} %>


<%
try
{
	  st=con.createStatement() ;
	  rs=st.executeQuery("select bname,datecreated from bankmaster where datecreated between '"+dte+"' and '"+dte1+"';");
while(rs.next()){
	name1=rs.getString(1);
	if((rs.getString(2)!=null && rs.getString(2)!=""))
	  {
	  dtecreate = rs.getString(2).toString().substring(0,rs.getString(2).toString().indexOf("."));
	  try
	 {
	 now = new  SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse( dtecreate);
	  sdf = new SimpleDateFormat("hh:mm:ss, dd-MM-yyyy");
	  intime = sdf.format(now);
	  }
	  catch (Exception e)
	  {
	  e.getMessage();
	  }
	  }
	%>


<tr><td>Cash and Bank Creation</td><td>New Cash and Bank Created <a href="#"><%=name1 %></a></td><td><%=intime %></td></tr>


<%}} 
catch(Exception e) {} %>
</table>
<br><br>
<center><a href="HomePage.jsp">Back to Home Page</a></center>
</body>
</html>